﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemo._05_数组
{
    class ArrayTest
    {
        public static void Test()
        {
            //1.声明数组
            int[] myArray;

            //2.给数组分配内存空间
            myArray = new int[5];

            //3.数组初始化语句
            int[] myArray2 = new int[5];
            int[] myArray3 = new int[] { 1, 2, 3, 4, 5 };
            int[] myArray4 = { 1, 2, 3, 4, 5 };

            //4.访问数组元素
            Console.WriteLine(myArray4[0]);

            //5.声明多维数组
            int[,] multiArray = new int[3, 3];
            int[,] multiArray1 = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };

            //6.声明锯齿数组
            int[][] jagged = new int[3][];
            jagged[0] = new int[2] { 1, 2 };
            jagged[1] = new int[3] { 3, 4, 5 };
            jagged[1] = new int[4] { 6, 7, 8, 9 };
        }
    }
}
